package com.xbongbong.saas.service.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.assembleproduct.pojo.dto.AssembleProductDeleteBatchDTO;
import com.xbongbong.pro.assembleproduct.pojo.vo.AssembleProductDeleteBatchVO;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.saas.model.AssembleProductModel;
import com.xbongbong.saas.service.AssembleProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/3/5 19:48
 * @since v1.0
 */
@Service("assembleProductService")
public class AssembleProductServiceImpl implements AssembleProductService {

    private static final Logger LOG = LoggerFactory.getLogger(AssembleProductServiceImpl.class);

    @Resource
    private AssembleProductModel assembleProductModel;

    @Override
    public AssembleProductDeleteBatchVO deleteBatch(AssembleProductDeleteBatchDTO assembleProductDeleteBatchDTO) throws XbbException {
        AssembleProductDeleteBatchVO assembleProductDeleteBatchVO = new AssembleProductDeleteBatchVO();
        try {
            List<Long> refId = assembleProductDeleteBatchDTO.getAssembleIdIn();
            String corpid = assembleProductDeleteBatchDTO.getCorpid();
            assembleProductModel.deleteByAssembleIdIn(refId, corpid);
            // TODO 日志
        } catch (Exception e) {
            LOG.error("AssembleProductServiceImpl.deleteBatch 执行出错：", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return assembleProductDeleteBatchVO;
    }
}
